package com.acoreful.acf2admin.test.webservice;

import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.acoreful.acf2admin.webservice.IHelloWorld;
import com.acoreful.acf2admin.webservice.IPay;

public class SpringClient {  
  
    public static void main(String args[]) {  
        ApplicationContext context = new ClassPathXmlApplicationContext("jaxws-cxf-client.xml");  
        accessService(context, "hw","小花");  
        accessService(context, "hw2","王二");  
        accessService(context, "hw3","张三");  
        //accessService(context, "hw4");  
        accessService2(context, "pay");  
        
        
    }  
      
    private static void accessService(ApplicationContext context, String beanName,String text) {  
        IHelloWorld hw = context.getBean(beanName, IHelloWorld.class);  
        System.out.println(hw.sayHello(StringUtils.defaultIfEmpty(text, "小明")));  
    }  
    private static void accessService2(ApplicationContext context, String beanName) {  
    	IPay hw = context.getBean(beanName, IPay.class);  
    	System.out.println(hw.sayHello("小明"));  
    }  
      
}  